<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>值类型和引用类型的特征 | JavaScript高级讲义</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../Sources/对象的动态特性.html" />
    
    
    <link rel="prev" href="../Sources/值类型和引用类型.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="1.4"
        data-chapter-title="值类型和引用类型的特征"
        data-filepath="Sources/值类型和引用类型的特征.md"
        data-basepath=".."
        data-revision="Tue Oct 18 2016 20:46:48 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        JavaScript高级讲义
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.1" data-path="Sources/内容简介.html">
            
                
                    <a href="../Sources/内容简介.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>0.1.</b>
                        
                        内容简介
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1" >
            
            <span><b>1.</b> JavaScript基础知识复习</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="Sources/基础复习题.html">
            
                
                    <a href="../Sources/基础复习题.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        基础复习题
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
            <span><b>1.2.</b> 内置对象与方法</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="Sources/array.html">
            
                
                    <a href="../Sources/array.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.1.</b>
                        
                        Array
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="Sources/date.html">
            
                
                    <a href="../Sources/date.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.2.</b>
                        
                        Date
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="Sources/number.html">
            
                
                    <a href="../Sources/number.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.3.</b>
                        
                        Number
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="Sources/boolean.html">
            
                
                    <a href="../Sources/boolean.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.4.</b>
                        
                        Boolean
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="Sources/string.html">
            
                
                    <a href="../Sources/string.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.5.</b>
                        
                        String
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="Sources/math.html">
            
                
                    <a href="../Sources/math.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.6.</b>
                        
                        Math
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="Sources/值类型和引用类型.html">
            
                
                    <a href="../Sources/值类型和引用类型.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        值类型和引用类型
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="1.4" data-path="Sources/值类型和引用类型的特征.html">
            
                
                    <a href="../Sources/值类型和引用类型的特征.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        值类型和引用类型的特征
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="Sources/对象的动态特性.html">
            
                
                    <a href="../Sources/对象的动态特性.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        对象的动态特性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="Sources/dom操作复习.html">
            
                
                    <a href="../Sources/dom操作复习.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        DOM操作复习
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="Sources/异常处理.html">
            
                
                    <a href="../Sources/异常处理.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.</b>
                        
                        异常处理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="Sources/调试工具的使用.html">
            
                
                    <a href="../Sources/调试工具的使用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.8.</b>
                        
                        调试工具的使用
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >JavaScript高级讲义</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x503C;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x7684;&#x7279;&#x5F81;">&#x503C;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x7684;&#x7279;&#x5F81;</h1>
<h2 id="1-&#x503C;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x7684;&#x8D4B;&#x503C;">1. &#x503C;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x7684;&#x8D4B;&#x503C;</h2>
<h3 id="11-&#x503C;&#x7C7B;&#x578B;&#x8D4B;&#x503C;&#xFF0C;&#x76F4;&#x63A5;&#x5C06;&#x503C;&#x590D;&#x5236;&#x4E00;&#x4EFD;">1.1. &#x503C;&#x7C7B;&#x578B;&#x8D4B;&#x503C;&#xFF0C;&#x76F4;&#x63A5;&#x5C06;&#x503C;&#x590D;&#x5236;&#x4E00;&#x4EFD;</h3>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> num1 = <span class="hljs-number">10</span>;
<span class="hljs-keyword">var</span> num2 = num1;
</code></pre>
<p>&#x4E0A;&#x9762;&#x4E24;&#x53E5;&#x4EE3;&#x7801;&#xFF0C;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#x7684;&#x4F53;&#x73B0;&#x4E3A;&#xFF1A;</p>
<p><img src="../Images/02-4.png" alt=""></p>
<ul>
<li><code>var num1 = 10;</code>&#x8868;&#x793A;&#x53D8;&#x91CF;num1&#x5B58;&#x50A8;&#x7684;&#x662F;&#x6570;&#x5B57;<code>10</code></li>
<li>&#x5C06;&#x6570;&#x636E;&#x62F7;&#x8D1D;&#x4E00;&#x4EFD;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5C06;<code>10</code>&#x62F7;&#x8D1D;&#x4E00;&#x4EFD;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x5185;&#x5B58;&#x4E2D;&#x6709;&#x4E24;&#x4E2A;<code>10</code></li>
<li>&#x5C06;&#x62F7;&#x8D1D;&#x7684;<code>10</code>&#x8D4B;&#x503C;&#x7ED9;<code>num2</code></li>
</ul>
<h3 id="12-&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x8D4B;&#x503C;&#xFF0C;&#x662F;&#x5C06;&#x5730;&#x5740;&#x590D;&#x5236;&#x4E00;&#x4EFD;">1.2. &#x5F15;&#x7528;&#x7C7B;&#x578B;&#x8D4B;&#x503C;&#xFF0C;&#x662F;&#x5C06;&#x5730;&#x5740;&#x590D;&#x5236;&#x4E00;&#x4EFD;</h3>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> p = {name:<span class="hljs-string">&quot;&#x5F20;&#x4E09;&quot;</span>, age:<span class="hljs-number">19</span>};
<span class="hljs-keyword">var</span> p1 = p;
</code></pre>
<p>&#x4E0A;&#x9762;&#x4E24;&#x53E5;&#x4EE3;&#x7801;&#xFF0C;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#x7684;&#x4F53;&#x73B0;&#x4E3A;&#xFF1A;</p>
<p><img src="../Images/02-5.png" alt=""></p>
<ul>
<li><code>var p = {name:&quot;&#x5F20;&#x4E09;&quot;, age:19};</code>,<code>p</code>&#x4E2D;&#x5B58;&#x50A8;&#x7684;&#x662F;&#x5BF9;&#x8C61;&#x7684;&#x5730;&#x5740;</li>
<li>&#x8D4B;&#x503C;&#x5C31;&#x662F;&#x5C06;&#x53D8;&#x91CF;<code>p</code>&#x4E2D;&#x5B58;&#x50A8;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5730;&#x5740;&#x62F7;&#x8D1D;&#x4E00;&#x4EFD;, &#x7136;&#x540E;&#x5C06;&#x8BE5;&#x6570;&#x636E;&#x8D4B;&#x503C;&#x7ED9;<code>p1</code></li>
<li>&#x6B64;&#x65F6;&#x5185;&#x5B58;&#x4E2D;&#x53EA;&#x6709; 1 &#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x53D8;&#x91CF;<code>p</code>&#x548C;<code>p1</code>&#x540C;&#x65F6;&#x6307;&#x5411;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;</li>
</ul>
<p><strong>&#x95EE;&#x9898;: &#x5229;&#x7528;<code>p1</code>&#x4FEE;&#x6539;&#x7684;<code>name</code>&#x5C5E;&#x6027;&#x4F1A;&#x5F71;&#x54CD;&#x5230;<code>p</code>&#x4E2D;&#x7684;<code>name</code></strong></p>
<h2 id="2-&#x503C;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x505A;&#x53C2;&#x6570;">2. &#x503C;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x505A;&#x53C2;&#x6570;</h2>
<p>&#x8003;&#x8651;&#x5982;&#x4E0B;&#x60C5;&#x51B5;&#xFF1A;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x662F;&#x591A;&#x5C11;&#xFF1F;</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">foo</span>(<span class="hljs-params">num</span>)</span>{
    num++;
}

<span class="hljs-keyword">var</span> a = <span class="hljs-number">1</span>;
foo(a);
<span class="hljs-built_in">console</span>.log(a);
</code></pre>
<p>&#x7EE7;&#x7EED;&#x8003;&#x8651;&#x5982;&#x4E0B;&#x60C5;&#x51B5;&#xFF1A;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x662F;&#x591A;&#x5C11;&#xFF1F;</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">foo</span>(<span class="hljs-params">o</span>)</span>{
    o.age++;
}

<span class="hljs-keyword">var</span> p = {name:<span class="hljs-string">&quot;&#x5F20;&#x4E09;&quot;</span>, age:<span class="hljs-number">19</span>};

foo(p);

<span class="hljs-built_in">console</span>.log(p.age);
</code></pre>
<p><strong>&#x603B;&#x7ED3;&#xFF1A;</strong></p>
<ul>
<li><p>&#x5728;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F20;&#x53C2;&#x7684;&#x8FC7;&#x7A0B;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x7528;&#x5B9E;&#x53C2;&#x7ED9;&#x5F62;&#x53C2;&#x8D4B;&#x503C;&#x7684;&#x8FC7;&#x7A0B;</p>
</li>
<li><p>&#x5F53;&#x53C2;&#x6570;&#x4E3A;&#x503C;&#x7C7B;&#x578B;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x51FD;&#x6570;&#x5185;&#x548C;&#x51FD;&#x6570;&#x5916;&#x7684;&#x4E24;&#x4E2A;&#x53D8;&#x91CF;&#x5B8C;&#x5168;&#x4E0D;&#x540C;&#xFF0C;&#x4EC5;&#x4EC5;&#x53EA;&#x662F;&#x5B58;&#x7684;&#x503C;&#x4E00;&#x6837;&#x800C;&#x5DF2;&#xFF0C;&#x4FEE;&#x6539;&#x65F6;&#x4E92;&#x4E0D;&#x5F71;&#x54CD;</p>
</li>
<li><p>&#x5F53;&#x53C2;&#x6570;&#x4E3A;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x51FD;&#x6570;&#x5185;&#x548C;&#x51FD;&#x6570;&#x5916;&#x7684;&#x4E24;&#x4E2A;&#x53D8;&#x91CF;&#x4E0D;&#x540C;&#xFF0C;&#x4F46;&#x662F;&#x5171;&#x540C;&#x6307;&#x5411;&#x540C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x5728;&#x51FD;&#x6570;&#x5185;&#x4FEE;&#x6539;&#x5BF9;&#x8C61;&#x6570;&#x636E;&#x65F6;&#x4F1A;&#x5F71;&#x54CD;&#x5916;&#x90E8;</p>
</li>
</ul>
<p>&#x6269;&#x5C55;&#xFF1A;</p>
<p>&#x8003;&#x8651;&#x5982;&#x4E0B;&#x60C5;&#x51B5;&#xFF1A;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x662F;&#x591A;&#x5C11;&#xFF1F;</p>
<pre><code class="lang-js">
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">foo</span>(<span class="hljs-params">o</span>)</span>{
    o = {name:<span class="hljs-string">&quot;&#x5F20;&#x4E09;&quot;</span>, age:<span class="hljs-number">18</span>};
}

<span class="hljs-keyword">var</span> p;
foo(p);

<span class="hljs-built_in">console</span>.log(p.age);
</code></pre>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../Sources/值类型和引用类型.html" class="navigation navigation-prev " aria-label="Previous page: 值类型和引用类型"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../Sources/对象的动态特性.html" class="navigation navigation-next " aria-label="Next page: 对象的动态特性"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
